package cn.shenshen.shop.util;


import org.apache.commons.codec.digest.DigestUtils;

public class DbUtil {
    private static String SALT = "1a2b3c4d";

    //进行数据库第一次密码加密
    public static String inputPassToFormPass(String password){
        //加盐
        password = "" +SALT.charAt(0) + SALT.charAt(2) +password + SALT.charAt(4) +SALT.charAt(5);
        String inputPass = DigestUtils.md5Hex(password);
        return inputPass;
    }

    public static String formPassToDbPass(String password,String salt){
        //加盐
        password = salt.charAt(0) + salt.charAt(2) + password + salt.charAt(4) +salt.charAt(5);
        String inputPass = DigestUtils.md5Hex(password);
        return inputPass;
    }

    public static void main(String[] args) {
        String inputPass = inputPassToFormPass("111111");
        System.out.println(inputPass);//f0771fe486c398d50dd12842e7e5d867
        //第二次加密
        System.out.println(formPassToDbPass(inputPass,SALT));//e6b0700978ce2302f9d807bdfc50467b
    }
}
